package com.api.main.mvc.web;

import com.api.main.mvc.service.DemoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @auther zhangwj
 * @date 2020/4/23 9:33 上午
 */
@RestController
@RequestMapping(value = "web")
public class WebController {

    @Resource
    private DemoService demoService;

    int code = 0;

    public static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    @GetMapping(value = "demo")
    public String demo() throws InterruptedException {
        int i;
        if (null != threadLocal.get()) {
            i = threadLocal.get();
        } else {
            i = 0;
        }
        threadLocal.set(i + 1);
        System.out.println("线程ID:" + Thread.currentThread().getId() + "值:" + threadLocal.get());
        System.gc();
        Thread.sleep(10000);
        return "111111";
    }
}